pub fn fib_loop(n:u8){
    let mut a=1;
    let mut b=1;
    let mut i=2u8;
    let mut c= a+b;
    loop {
        (a,b,c)= generate_next( a, b);
        i+=1;
        println!("fib_loop next value is {},at level{}",b,i);
        if i >= n { break; }
    }
}

pub fn while_loop(n:u8){
    let (mut a,mut b,mut i)=(1,1,2u8);
    let mut c =a+b;
    while i <= n {
        (a,b,c)= generate_next( a, b);
        i+=1;
        println!("while_loop next value is {}, at level {}",c,i)
    }
}

fn generate_next(mut a: i32, mut b: i32) -> ( i32, i32, i32) {
    let c = a + b;
    a = b;
    b = c;
    (a,b,c)
}

pub fn fib_for(n:u8){
    let (mut a,mut b)=(1,1);
    let mut c =a+b;
    for i in 2..n {
        (a,b,c)= generate_next(a, b);
        println!("for_lib next value is {}, at position {}",c,i)
    }
}